<?php

if (! defined('BASEPATH'))
    exit('No direct script access allowed');

/* CI_Controller扩展类 */
class C_Controller extends CI_Controller
{

    public function __construct()
    {
        // 继承父类构造函数
        parent::__construct();
        // 开启session
        if (!isset($_SESSION)) {
            session_start();
        }
        date_default_timezone_set('PRC');
        header("Content-type:text/html;charset=utf-8");
        $this->load->helper('url');
        // 判断用户登录状态
        if (!isset($_SESSION['admin_info'])) {
            header('LOCATION:/site/login');
            die();
        }
        if ($_SESSION['admin_info']['state'] == 0) {
            redirect('/site/logout', '该账号未通过审核');
        }
    }
    public function load_view($path, $data, $header, $class ,$sidebar = null)
    {
//        echo get_class();
        if (isset($_SERVER["HTTP_X_PJAX"])) {
            $this->load->view($class.'/' . $path, $data);
        } else {
            $this->load->view('header', $header);
            $this->load->view('sidebar', $sidebar);
            $this->load->view($class.'/' . $path, $data);
            $this->load->view('footer');
        }
    }
}
/* End of file MY_Controller.php */
/* Location: ../application/core/MY_Controller.php */